package com.ttg.web.dao.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.model.mapper.AdminRoleLangMapper;
import com.ttg.model.pojo.AdminRoleLang;
import com.ttg.web.dao.AdminRoleLangDao;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ZQ
 * @version 1.0
 * @Description
 * @date 2021/3/9 18:04
 */
@Service
public class AdminRoleLangDaoImpl extends ServiceImpl<AdminRoleLangMapper, AdminRoleLang> implements AdminRoleLangDao {


    @Override
    public AdminRoleLang getArlByRoleId(Long roleId ,String arlLang) {
        LambdaQueryWrapper<AdminRoleLang> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AdminRoleLang::getArlRoleId,roleId).eq(AdminRoleLang::getArlLang,arlLang);
        return getOne(wrapper);
    }

    @Override
    public AdminRoleLang findRoleByRoleIdAndLang(Long roleId,String lang) {
        LambdaQueryWrapper<AdminRoleLang> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AdminRoleLang::getArlRoleId,roleId)
                .eq(AdminRoleLang::getArlLang,lang);
        return getOne(wrapper);
    }

    @Override
    public List<AdminRoleLang> selectList(List<Long> roleIds, String lang) {
        LambdaQueryWrapper<AdminRoleLang> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AdminRoleLang::getArlLang, lang)
                .in(AdminRoleLang::getArlRoleId, roleIds);
        return list(wrapper);
    }

}
